var dayjs = require('dayjs')

function utcNode(type,date) {
    function condition() {
        return type==='utc'
    }

    function serialization() {
        return dayjs(date).format("YYYY-MM-DD'T'HH:mm:ss.SSS'Z'")
    }
    return {condition:condition, serialization: serialization}
}

function timeStamp(type,date) {
    function condition() {
        return type==='timestamp'
    }

    function serialization() {
        return dayjs(date).valueOf()
    }
    return {condition:condition, serialization: serialization}
}

function ordinary(type,date) {
    function condition() {
        return type==='ordinary'
    }

    function serialization() {
        return dayjs(date).format("YYYY-MM-DD HH:mm:ss")
    }
    return {condition:condition, serialization: serialization}
}

const nodes = [utcNode, timeStamp, ordinary]
for (let node of nodes) {
    let {condition,serialization} = node("utc",new Date());
    if (condition()) {
       const date= serialization()
        console.log(date)
    }
};